package com.stylefeng.guns.modular.vpn_real_time_data.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.VpnRealTimeData;
import com.stylefeng.guns.modular.vpn_real_time_data.service.IVpnRealTimeDataService;

/**
 * 实时数据控制器
 *
 * @author fengshuonan
 * @Date 2020-03-11 11:30:32
 */
@Controller
@RequestMapping("/vpnRealTimeData")
public class VpnRealTimeDataController extends BaseController {

    private String PREFIX = "/vpn_real_time_data/vpnRealTimeData/";

    @Autowired
    private IVpnRealTimeDataService vpnRealTimeDataService;

    /**
     * 跳转到实时数据首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "vpnRealTimeData.html";
    }


    /**
     * 获取实时数据列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return vpnRealTimeDataService.selectList(null);
    }

    /**
     * 今日实时汇总数据
     * @return
     */
    @RequestMapping(value = "/todayTotalRealtimeData")
    @ResponseBody
    public Object todayTotalInfo(){
        return vpnRealTimeDataService.getTodayRealTime();
    }

    /**
     * echarts实时数据
     * @param  type 查询数据类型，1-注册用户数，2-上线用户数，
     *              3-在线时长，4-新增付费用户数，5-新增付费率
     * @return
     */
    @RequestMapping("/echartsRealTimeInfo")
    @ResponseBody
    public Object echartsRealTimeInfo(@RequestParam(value = "type",required = false) String type){
        return vpnRealTimeDataService.echartsRealTimeInfo(type);
    }

    @RequestMapping("/detailOfTodayRealTimeInfo")
    @ResponseBody
    public Object detailOfTodayRealTimeInfo(){
        return vpnRealTimeDataService.getDetailOfTodayRealTime();
    }

}
